package com.smartHome.mapper;

import com.smartHome.pojo.dto.SceneDto;
import com.smartHome.pojo.entity.Scene;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SceneMapper {
    @Select("select * from scenes where room_id = #{roomId}")
    List<Scene> getSceneList(Integer roomId);

    @Update("UPDATE scenes SET time_Open=#{timeOpen},isOn = #{isOn}, update_time = NOW() WHERE scene_id = #{sceneId}")
    void updateScene(Scene scene);

    @Insert("insert into scenes(room_id, scene_name, time_open,isOn,create_time, update_time) " +
            "values(#{roomId}, #{sceneName},#{timeOpen},0 ,now(), now())")
    @Options(useGeneratedKeys = true, keyProperty = "sceneId")
    void addScene(Scene scene);

    @Delete("DELETE from scenes where scene_id = #{sceneId}")
    void deleteScene(Integer sceneId);

    @Select("select * from scenes where isOn = 1")
    List<Scene> getSceneNumber();
}
